package views;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import business.interfaces.ICalendarioClase;
import business.interfaces.ICliente;
import business.interfaces.ISocio;
import data.entities.CalendarioClase;
import data.entities.Cliente;
import data.entities.Socio;



@SuppressWarnings("serial")
public class SociosTableModel extends AbstractTableModel {

	private static final int DNI = 0;
	private static final int NOMBRE = 1;
	private static final int TELEFONO = 2;
	private static final int EMAIL = 3;

	
	private List<ISocio> socios;

	final static String[] columnNames = { "DNI", "Nombre completo", "Telefono", "Email"};

	boolean isEditable = false;

	public SociosTableModel(List<ISocio> socios) {
		this.socios = socios;
	}

	public String getColumnName(int col) {
		return columnNames[col];
	}

	public int getRowCount() {
		return socios.size();
	}

	public int getColumnCount() {
		return columnNames.length;
	}

	public Object getValueAt(int row, int col) {
		Object result = null;
		Socio socio = (Socio) (socios.get(row));
		switch (col) {
		case DNI:
			result = socio.getDni();
			break;
		case NOMBRE:
			result = socio.getNombre();
			break;
		case TELEFONO:
			result = socio.getTelefono();
			break;
		case EMAIL:
			result = socio.getEmail();
			break;
		}
		return result;

	}
	
	public ISocio getUbicacionAtRow(int r) {
		ISocio result = null;
		try {
			result = socios.get(r);
		} catch (IndexOutOfBoundsException e) {
			System.out.println("No has elegido ningun socio.");
		}
		
		return result;
	}

	public boolean isCellEditable(int row, int col) {
		return isEditable;
	}

	public void setEditable(boolean isEditable) {
		this.isEditable = isEditable;
	}

	public void setValueAt(Object value, int row, int col) {
	}
}
